#include<bits/stdc++.h>
using namespace std;
const int num=1e5+1;
int t,n,m,l,v;
double p[num];
int flag[num];
int tol,ans;

struct node{
	double di,vi,ai;
	double s,e,l;
}car[num];

bool cmp(node a,node b){
	if(a.s==b.s) return a.e<b.e;
	return a.s<b.s;
}

int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>t;
	for(int k=0;k<t;k++){
		tol=0;
		ans=0;
		scanf("%d%d%d%d",&n,&m,&l,&v);
		for(int i=0;i<n;i++){
			flag[i]=1;
			//cin>>car[i].di>>car[i].vi>>car[i].ai;
			scanf("%le%le%le",&car[i].di,&car[i].vi,&car[i].ai);
			if(car[i].vi<=v&&car[i].ai<=0){
				car[i].s=-1;
				car[i].e=-1;
				car[i].l=-1;
			}
			else if(car[i].vi>v&&car[i].ai>=0){
				car[i].l=car[i].di;
			}
			else{
				double x=car[i].vi;
				double y=car[i].ai;
				car[i].s=-1;
				car[i].e=-1;
				car[i].l=car[i].di+(v*v-x*x)*0.5/y;
			}
		}
		for(int i=0;i<m;i++) cin>>p[i];
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				if(car[j].l==-1) continue;
				if(car[j].ai>=0){
					if(p[i]>car[j].l){
						if(flag[j]){
							flag[j]=0;
							car[j].s=i;
							tol++;
						}
						car[j].e=i;
					}
				}
				else{
					if(p[i]<car[j].l&&p[i]>=car[j].di){
						if(flag[j]){
							flag[j]=0;
							car[j].s=i;
							tol++;
						}
						car[j].e=i;
					}
				}
			}
		}
		sort(car,car+n,cmp);
		int index=0;
		while(car[index].s==-1) index++;
		int cnt=car[index].e;
		ans=1;
		for(int i=index+1;i<n;i++){
			if(car[i].s>cnt){
				ans++;
				cnt=car[i].e;
			} 
			if(car[i].e<cnt){
				cnt=car[i].e;
			}
		}
		printf("%d %d\n",tol,m-ans);
	}
	return 0;
}
